<?php

# LOGIN.PHP

# Form login



session_start();

ob_start();



define('INDEX',true);

define('ADMIN_LOGIN',true);



// Include required files

require("_config/config.php"); // Config file

require("_config/db_connection.php"); // DB Connection

require("common/functions_mysql.php"); // MySQL class

require("common/functions_common.php"); // Common functions

require("common/functions_template.php"); // Templates functions

require("common/functions_jcas.php"); // jCAS's function

require("common/init.php"); // Initial file

require("common/lang_".$cfg['admin_language'].".php"); // Language file

require("core/class_jcas.php"); // Core jcas


?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">

<html>

<head>

<title><?php echo $cfg['admin_header']?></title>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg['default_charset']; ?>">

<meta http-equiv="PRAGMA" content="NO-CACHE">

<script src="js/functions.js" language="JavaScript" type="text/javascript"></script>

<link href="css/style.css" rel="stylesheet" type="text/css">

</head>

<?php

// Logout

if($_GET['act']=='logout')

{

	echo login_do_logout();

	exit;

}



// If admin not login, show login form

if(!$admin_session["admin_id"])

{

	?>

	<body style="background-color:#FFFFFF " onLoad="document.frm_login.user_name.focus()">

	<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">

	<tr><td align="center" valign="middle">

	<?php

	// Login action

	echo login_action();

	

	// Show login form

	if($show_content)

	{

		$_SESSION['admin_login_code'] = rand(11111,99999);

	?>

		  <table width="550"  border="0" cellspacing="0" cellpadding="1">

			<tr> 

			  <td>&nbsp;</td>

			  <td style="font-size:17px; font-weight:bold"><?=$cfg['admin_header']?></td>

			</tr>

			<tr> 

			  <td width="1"><img src="images/administrator.gif" width="90" height="90">		  </td>

			  <td width="100%">

			  <?php echo js_validate("user_name,password,admin_login_code","frm_login");?>

			  <table width="100%"  border="0" cellspacing="0" cellpadding="3" align="center" >

				<form name="frm_login" method="post" action="login.php" onSubmit="return validate_frm_login()">

				  <tr>

					<td colspan="2" class="headtd"><?php echo $lang['login_title']?></td>

				  </tr>

				  <tr >

					<td width="30%" class="row1td"><?php echo $lang['admin_user']?></td>

					<td width="70%" class="row2td"><input type="text" name="user_name" id="user_name" size="30" maxlength="30"></td>

				  </tr>

				  <tr >

					<td class="row1td"><?php echo $lang['admin_pwd']?></td>

					<td class="row2td"><input type="password" name="password" id="password" size="30" maxlength="30"></td>

				  </tr>
			 

				  <tr >

					<td class="row1td"><?php echo $lang['admin_login_code']?></td>

					<td class="row2td"><div style="float:left"><input type="text" name="admin_login_code" id="admin_login_code" size="6" maxlength="6" value="<?php echo $_SESSION['admin_login_code']?>"></div> <div style="float:left"><img src="common/code.img.php?code_id=admin_login_code" /></div></td>

				  </tr>
 

				  <tr >

					<td colspan="2" align="center" class="row2td"><input type="submit" name="login" class="button" value="<?php echo $lang['btn_login']?>"></td>

				  </tr>

				  <input type="hidden" name="session_id" value="<?php echo session_id();?>">

				</form>

			  </table></td>

			</tr>

			<tr> 

			  <td align="left">&nbsp;</td>

			  <td align="left"><font class="info"><?php echo $lang['system_requirements']?></font></td>

			</tr>

		  </table>

	<?php

	}

	?>

	</td>

	  </tr>

	</table>

	

	<?php

}

else

{

	echo '<script> parent.location=\'index.php\'; </script>';

	echo '<br/><div align="center">You\'ve already logged in ... </div>';

	exit;

}

?>

</body>

</html>

<?php

$DB->close();

require("common/debug.inc.php");



?>

